package com.gg.cart.controller;

import com.gg.cart.service.CartService;
import com.gg.cart.service.impl.CartServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "UpdateCartByCidForCcountServlet", value = "/cart/UpdateCartByCidForCcountServlet")
public class UpdateCartByCidForCcountServlet extends HttpServlet {
    private CartService  cartService =  new CartServiceImpl();
    /*$.post()*/
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        /*1.获取请求参数*/
        /*cid  ,  count*/
        String cid = request.getParameter("cid");
        Integer count  = Integer.parseInt(request.getParameter("count")) ;
        /*2.调用更新数量业务*/
        boolean res = cartService.updateCartByCidForCcount(cid,count);
        /*3.返回结果*/
        response.getWriter().print(res);
    }
}
